
/**
 * Project Name:cats-web
 * File Name:WserviceController.java
 * Package Name:com.catsic.web.controllers
 * Date:2014年8月25日上午9:03:56
 * Copyright (c) 2014, oa.catsic.com All Rights Reserved.
 */
 
package com.catsic.web.controllers;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.catsic.base.controller.BaseController;
import com.catsic.mod.condition.WserviceCondition;
import com.catsic.mod.constant.Constants;
import com.catsic.mod.form.WserviceForm;
import com.catsic.mod.service.WserviceService;
import com.catsic.pub.form.DrawerForm;

/**
 * ClassName: WserviceController
 * Description: 接口管理控制器
 * date: 2014年4月3日 上午9:03:56
 * author: yangyd
 */
@Controller
@RequestMapping("/wservice")
public class WserviceController extends BaseController{
	
	@Autowired
	private WserviceService wserviceService;
	
//	@Autowired
//	private WserviceService drawerService;
	
    /**
     * 查询
	 * @author yangyd
	 * @return
	 */
	@RequestMapping(value = "/query")
	@ResponseBody
	public Map<String,Object> query(WserviceCondition condition,Pageable  pageable){
		Map<String,Object> map = new HashMap<String, Object>();
		Page<WserviceForm> page= wserviceService.findAll(condition,pageable);
        map.put(CONTENT, page);
        map.put(RESULT, RESULT_SUCCESS);
		return map;
	}
	
	/**
	 * create:创建
	 * @author yangyd
	 * @param wservice
	 * @return
	 */
	@RequestMapping(value = "/create" , method = RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> create(WserviceForm form){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put(CONTENT, wserviceService.add(form));
		map.put(RESULT, RESULT_SUCCESS);
		return map;
	}
	
	/**
	 * update:更新
	 * @author yangyd
	 * @param wservice
	 * @return
	 */
	@RequestMapping(value = "/update" , method = RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> update(WserviceForm form){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put(CONTENT, wserviceService.update(form));
		map.put(RESULT, RESULT_SUCCESS);
		return map;
	}
	
	/**
	 * report:报送
	 * @author yangyd
	 * @param wservice
	 * @return
	 */
	@RequestMapping(value = "/report" , method = RequestMethod.GET)
	@ResponseBody
	public Map<String,Object> report(String id){
		Map<String,Object> map = new HashMap<String, Object>();
		wserviceService.report(id);
		map.put(RESULT, RESULT_SUCCESS);
		return map;
	}
	
	@RequestMapping(value = "/list" )
	@ResponseBody
	public Map<String,Object> list(String pid){
		Map<String,Object> map = new HashMap<String, Object>();
		List<DrawerForm> drawerList = wserviceService.findByDrawerNotWservice(pid,Constants.接口服务类型);
		map.put(CONTENT, drawerList);
		map.put(RESULT, RESULT_SUCCESS);
		return map;
	}

}
